package com.cx.common.util;

import ma.glasnost.orika.MapperFactory;
import ma.glasnost.orika.impl.DefaultMapperFactory;
import ma.glasnost.orika.impl.MapperFacadeImpl;

import java.util.List;

/**
 * @author flysand
 * @package com.cx.common.util
 * @date 2021-11-11 20:59
 * @des ObjectUtils:对象的相关操作 如：对象属性copy
 */
public class ObjectUtils {

    private static MapperFactory mapperFactory = new DefaultMapperFactory.Builder().build();

    public static <T,S> List<T> copyList(List<S> source, Class<T> target) {
        return mapperFactory.getMapperFacade().mapAsList(source, target);
    }

    public static <T,S> T copyObject(S source, Class<T> target){
        return mapperFactory.getMapperFacade().map(source, target);
    }


}
